package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.config.battle.PatronsBattleDetail;
import com.yanqu.road.pb.common.BattleProto;

import java.util.List;

public class BattlePb {

	public static BattleProto.BattleDetailTempMsg.Builder parseBattleDetailTempMsg(PatronsBattleDetail battleDetail) {
		if(null == battleDetail){
			return null;
		}
		BattleProto.BattleDetailTempMsg.Builder msg = BattleProto.BattleDetailTempMsg.newBuilder();
		msg.setMyPatronsId(battleDetail.getMyPatronsId());
		msg.setMyPatronsBlood(battleDetail.getMyPatronsTotalBlood().toString());
		msg.setMyPatronsCurrentBlood(battleDetail.getMyPatronsCurrentBlood().toString());
		msg.setEnemyPatronsId(battleDetail.getEnemyPatronsId());
		msg.setEnemyPatronsBlood(battleDetail.getEnemyPatronsTotalBlood().toString());
		msg.setEnemyPatronsCurrentBlood(battleDetail.getEnemyPatronsCurrentBlood().toString());
		msg.setNo(battleDetail.getNo());
		return msg;
	}

	public static BattleProto.BattleDetailListMsg.Builder parseBattleDetailListMsg(List<PatronsBattleDetail> battleDetailList) {
		BattleProto.BattleDetailListMsg.Builder listMsg = BattleProto.BattleDetailListMsg.newBuilder();
		if(null != battleDetailList){
			for(PatronsBattleDetail battleDetail : battleDetailList){
				BattleProto.BattleDetailTempMsg.Builder msg = parseBattleDetailTempMsg(battleDetail);
				if(null != msg){
					listMsg.addBattleDetailList(msg);
				}
			}
		}
		return listMsg;
	}
}
